import java.time.LocalDate;
public class Transaction {
    private LocalDate date;
    private double amount;
    private String category;
    private String remark;

    public Transaction(LocalDate date,double amount,String category,String remark){
        if (amount < 0) {
            throw new IllegalArgumentException("金额必须为正数。");
        }
        this.date = date;
        this.amount = amount;
        this.category = category;
        this.remark = remark;
    }
    public LocalDate  getDate(){
        return date;
    }
    public double getAmount(){
        return amount;
    }
    public String getCategory(){
        return category;
    }
    public String getRemark(){
        return remark;
    }
    public String toString() {
        return String.format("日期: %s, 金额: %.2f, 类别: %s, 备注: %s", date, amount, category, remark);
    }
}

